Click Here!



home account info subscribe login search FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Bug Proofing Visual Basic: A Guide to Error Handling and Prevention
(Publisher: John Wiley & Sons, Inc.)
Author(s): Rod Stephens
ISBN: 0471323519
Publication Date: 11/01/98

Search this book:
 
INTRODUCTION

Part One—Work Environment
CHAPTER 1—Programming Philosophy
Manage Properly
Fight Bugs Every Step of the Way
Catch Bugs Early
Stay in Control
Intercept Unnecessary Work
Set Priorities
Change Priorities
Defer Optimization
Don’t Optimize
Get It Working First
Be Steady and Thorough
Code Offensively
Write for Others
Write for Humans
Code for the Ages
Code without Ego
Self-Test
Summary
CHAPTER 2—Work Habits
Keep a Notebook
Keep a Bug Log
Analyze the Bug Log
Save Everything
Do It Now
Fix It Now
Test It Now
If It Works, Don’t Fix It
Don’t Fiddle
Design Before You Code
Code When You Are Alert
Code in Manageable Pieces
Close Your Door
Self-Test
Summary

Part Two—Coding Style
CHAPTER 3—Variables
Explicitly Declare Variables
Use Option Explicit
Don’t Use Deftype Statements
Use Hungarian Notation
Hungarian Specifics
Purpose
A Word of Caution
Use Meaningful Names
Capitalize Consistently
Avoid Name Conflicts
Limit Scope
Use Static Variables
Use Specific Data Types
Use TypeOf and TypeName
Avoid Variants
Use Variant Subtype Functions
Beware the One Form
Self-Test
Summary
CHAPTER 4—Constants and Enums
Use No Magic Numbers
Dimension Arrays with Constants
Use NUM and MAX Constants
Use LBound and UBound
Give Related Values Related Names
Add and Remove Values with Care
Define Enumerated Values
Group Related Values
Self-Test
Summary
CHAPTER 5—Exposing Bugs
Verify Arguments
Use Debug.Assert
Use Stop
Validate Optional Parameters
Use Default Values
Avoid Optional Parameters
Name Optional Parameters
Validate ParamArray Parameters
Stop or Raise Errors When Appropriate
Use Tight Restrictions
Use LBound and UBound
Validate Data Structures
Validate at Startup
Validate at Shutdown
Validate While Running
Validate Forms and Classes
Clear Unused Variables
Use Else Statements
Verify Results
Self-Test
Summary
CHAPTER 6—Being Obvious
Don’t Use Clever Tricks
Document Tricks
Don’t Write Routines with Side Effects
Mix Data Types Cautiously
Use & and + Correctly
Mix Booleans and Integers Cautiously
Parenthesize Complex Expressions
Use Left$
Open and Close Files in the Same Routine
Put Separate Commands on Separate Lines
Specify Lower Bounds for Arrays
Don’t Use Static Routines
Use Private and Public
Use ByVal and ByRef
Use Line Continuation
Use Explicit Properties
Eliminate Random Behavior
Perform Short Actions First
Avoid Wizards
Use Meaningful Names
Standardize Abbreviations
Use Similar Names for Similar Purposes
Don’t Reuse Variables
Use Next i
Self-Test
Summary
CHAPTER 7—Comments
Comment Files
Identifying Information
Description
Entry Points
Dependencies
Known Issues
Method
Declarations
Example File Header
Comment Routines
Comment Event Handlers
Give Context, Not Content
Comment Portability Issues
Comment Plainly
Don’t Comment Continued Statements
Don’t Remove Comments
Format Comments Nicely
Use Lots of Comments
Self-Test
Summary
CHAPTER 8—Gotchas
Watch Precision in Tests
Control Float Loops with While
Control Float Loops with Integers
Control Date Loops
Don’t Resize Inside Loops
Watch for Circular References
Understand Form Lifetime
Initialize All Values
Use All Values
Return a Value
Beware Foreign Syntax
Never Use GoTo, Except...
Use GoTo for Error Handling
Use GoTo to Simplify
Exit in One Place
Exit before Error Handlers
Don’t Use IIF
Watch for Overflow and Underflow
Watch for Divide by 0
Be Aware of Argument Promotion
Avoid Error Codes
Don’t Assume Variable Sizes
Don’t Assume Constant Values
Self-Test
Summary

Part Three—Development
CHAPTER 9—Design
Design for Uniformity, Simplicity, Elegance
Avoid Creeping Featuritis
Start with Minimal Functionality
Avoid “Not Invented Here” Syndrome
Avoid the Bleeding Edge
Avoid Third-Party Products
Optimize Design, Not Code
Defer Optimization
Indent Consistently
Remove or Assert Assumptions
Catch Invalid Situations
Raise Errors for Exceptions
Use Enums for Status Codes
Return the Worst Data Possible for Errors
Don’t Use One Input for Multiple Purposes
Don’t Use One Output for Multiple Purposes
Keep Separate Tasks Separate
Examine Decisions Closely
Use FreeFile
Use ByVal
Separate Debug and Nondebug Code
Self-Test
Summary
CHAPTER 10—Encapsulation
Hide Internals
Encapsulate with Classes
Count Object Creation and Destruction
Initialize Objects
Use Property Procedures
Use Implements
Encapsulate with Types
Encapsulate with Controls
Encapsulate with Modules
Encapsulate with Subroutines
Encapsulate Errors
Encapsulate with Variables
Save Property Values
Use With
Don’t Use Nested Withs
Don’t Repeat Code
Encapsulate Library Calls
Self-Test
Summary
CHAPTER 11—Optimization
Optimize Algorithms
Defer Optimization
Profile First
Comment Optimizations
Use Slow Debugging Code
Understand Visual Basic’s Optimizations
Assume No Aliasing
Remove Array Bounds Checks
Remove Integer Overflow Checks
Remove Floating-Point Error Checks
Allow Unrounded Floating-Point Operations
Remove Safe Pentium FDIV Checks
Self-Test
Summary

Part Four—Error Handling
CHAPTER 12—Error Handling Fundamentals
Use On Error
On Error GoTo 0
On Error Resume Next
On Error GoTo Line
Leave Error Handlers
Resume
Resume Next
Exit Sub/Function/Property
End Sub/Function/Property
Err.Raise
Define Error Constants
Keep Error Handlers Separate
Understand Error Handler Scope
Don’t Nest Error Handlers
Write Bugproof Error Handlers
Always Be Prepared
Clean Up
Handle Errors in Objects
Handle Other Object Errors
Break on Errors
Self-Test
Summary
CHAPTER 13—Standard Error Handlers
Use a Systematic Approach
Catch Error Events
Present Error Messages
Unwind the Stack
Save Errors in a File
Save Errors in a Database
Send Email
Self-Test
Summary

Part Five—Post-Coding Activities
CHAPTER 14—Testing
Use Many Tests
Testing Techniques
Test Scope
Development Phase
Step through the Code
Hold Code Reviews
Test Exhaustively
Perform Black Box Testing
Perform White Box Testing
Consider Global Variables
Plan Tests
Test Continuously
Have the Proper Attitude
Write Test Routines
Look for Bugs
Test When You Are Alert
Test It Anyway
Test Ported Code
Start from the Immediate Window
Examine Variables
Modify Variables
Use Ctrl-F9
Examine Decision Statements
Anticipate Outputs
Fake Errors
Find Your Own Bugs
Have Someone Else Test Your Code
Don’t Shoot the Messenger
Fix Your Own Code
Simulate User Actions
Check Code Coverage
Keep Testing
Estimate the Number of Bugs
Estimate Bug Finding Time
Test User Interfaces from the Top Down
Test Code from the Bottom Up
Perform a Postmortem
Self-Test
Summary
CHAPTER 15—Profiling
Installing VB Code Profiler
How VBCP Works
Using VBCP
Analyzing Results
Line Timing
Function Timing
Line Hit Counting
Function Hit Counting
Self-Test
Summary
CHAPTER 16—Debugging Habits
Think First
Debug When You Are Alert
Code Properly While Debugging
Fix Your Own Bugs
Fix It Now
Come Back Later
Comment Repairs
See What Changed
Don’t Believe in Magic
Fix Routines, Not Lines
Fix Bugs, Not Symptoms
Look for Multiple Bugs
Do Not Experiment
Test Fixes
Simplify
Examine Decisions Closely
Look for Bugs Where There Are Bugs
Self-Test
Summary
APPENDIX A
APPENDIX B
INDEX

Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.